package com.ruoyi.framework.config;

import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.ResourceHandlerRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;

@Configuration
public class WebConfig implements WebMvcConfigurer {

    @Value("${ruoyi.profile}")
    private String UPLOAD_DIR ; // 指定上传目录


     @Override
     public void addResourceHandlers(ResourceHandlerRegistry registry) {
     // 映射 /upload/* 到文件系统中的 C:/serve/upload 目录
     registry.addResourceHandler("/static/img/**")
     .addResourceLocations("file:"+UPLOAD_DIR); // 外部路径
//
//     // 映射 /img/* 到文件系统中的某个目录（例如，/static/img/）
//     registry.addResourceHandler("/img/**")
//     .addResourceLocations("classpath:/static/img/");
     }
}
